package com.hmall.gateway.filters;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class MyGlobalFilter implements GlobalFilter, Ordered {


    /**
     * 实现接口的方法
     * @param exchange
     * @param chain
     * @return
     */
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        //模拟jwt令牌逻辑
        HttpHeaders headers = exchange.getRequest().getHeaders();
        System.out.println(headers);
        return chain.filter(exchange);//共享参数
    }

    @Override
    public int getOrder() {
        //返回测试优先级
        return 0;
    }
}
